package com.itqf.controller;

import com.itqf.entity.ScheduleJob;
import com.itqf.service.ScheduleJobService;
import com.itqf.utils.R;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description:
 * @Company: 千锋互联
 * @Author: 李丽婷
 * @Date: 2020/10/21
 * @Time: 上午9:51
 */
@RestController
public class ScheduleJobController {

    @Resource
    private ScheduleJobService scheduleJobService;

    @RequestMapping("/schedule/job/list")
    public R scheduleList(int limit,int offset,String search,String order){
        return scheduleJobService.scheduleJobList(limit,offset,search,order);
    }

    @RequestMapping("/schedule/job/save")
    public  R   save(@RequestBody ScheduleJob scheduleJob){
        return  scheduleJobService.saveScheduleJob(scheduleJob);
    }
    @RequestMapping("/schedule/job/del")
    public  R   delete(@RequestBody List<Long> ids) {
        return  scheduleJobService.deleteScheduleJob(ids);
    }
    //修改

    @RequestMapping("/schedule/job/info/{jobId}")
    public   R info(@PathVariable("jobId") long jobId){
        System.out.println(jobId);
        return  scheduleJobService.scheduleInfo(jobId);
    }

    @RequestMapping("/schedule/job/update")
    public  R   update(@RequestBody ScheduleJob scheduleJob) {
        return  scheduleJobService.updateScheduleJob(scheduleJob);
    }
    //修改结束


    @RequestMapping("/schedule/job/pause")
    public  R   pause(@RequestBody List<Long> ids) {
        return  scheduleJobService.pauseScheduleJob(ids);
    }
    @RequestMapping("/schedule/job/resume")
    public  R   resume(@RequestBody List<Long> ids) {
        return  scheduleJobService.resumeScheduleJob(ids);
    }
    @RequestMapping("/schedule/job/run")
    public  R   run(@RequestBody List<Long> ids) {
        return  scheduleJobService.runOneScheduleJob(ids);
    }





}
